package com.viphuli.app.tool.adapter;

import java.util.List;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;

import com.offroader.utils.ViewUtils;
import com.viphuli.app.tool.R;
import com.viphuli.app.tool.bean.part.CircleHospital;
import com.viphuli.app.tool.common.MyApp;

public class CircleHospitalListAdapter extends BaseAdapter {

	private List<CircleHospital> list;

	public CircleHospitalListAdapter(List<CircleHospital> list) {
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int index) {
		return list.get(index);
	}

	@Override
	public long getItemId(int index) {
		return index;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		ViewHolder holder = null;

		if (convertView == null || convertView.getTag() == null) {
			convertView = ViewUtils.inflateView(MyApp.getInstance(), R.layout.item_circle_hospital_list);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		CircleHospital hospital = list.get(position);
		holder.nameText.setText(hospital.getName());
		
		return convertView;
	}
	
	protected class ViewHolder {
		
		@Bind(R.id.id_home_item_name)
		TextView nameText;
		
		public ViewHolder(View view) {
			ButterKnife.bind(this, view);
		}
	}

}
